package o;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.PopupMenu;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import o.azf.e;

public class bal {
    private static Map<String, Class<? extends baq>> ˊ = new HashMap();
    private static Map<String, Integer> ˏ = new HashMap();
    private String ˋ = null;
    private List<String> ˎ = null;
    private String ॱ = null;

    static class a extends evx {
        private baq ˋ;

        public a(baq o_baq) {
            this.ˋ = o_baq;
        }

        public void ˋ(View view) {
            this.ˋ.ˎ();
        }
    }

    static {
        ˊ.put("02", bap.class);
        ˊ.put("03", bao.class);
        ˊ.put("04", baj.class);
        ˏ.put(KeyAndValue.NUMBER_01, Integer.valueOf(e.ˏ));
        ˏ.put("05", Integer.valueOf(e.ˋ));
    }

    public String ˎ() {
        return this.ˋ;
    }

    public void ˎ(String str) {
        this.ˋ = str;
    }

    public void ˊ(String str) {
        this.ॱ = ˋ(str);
    }

    public void ॱ(String str) {
        this.ˎ = ᐝ(str);
    }

    private String ˋ(String str) {
        if (dof.ˋ(str)) {
            return KeyAndValue.NUMBER_01;
        }
        try {
            String[] split = str.split("\\|");
            if (split.length > 1) {
                return "00";
            }
            if (ˏ(split[0])) {
                return split[0];
            }
            return KeyAndValue.NUMBER_01;
        } catch (Exception e) {
            azh.ˏ.ˏ("ShowControlMore", "parseLeft error:" + str);
            return KeyAndValue.NUMBER_01;
        }
    }

    private boolean ˏ(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        if ("00".equals(str) || ˏ.containsKey(str)) {
            return true;
        }
        return false;
    }

    private List<String> ᐝ(String str) {
        List arrayList = new ArrayList();
        if (!dof.ˋ(str)) {
            try {
                for (Object obj : str.split("\\|")) {
                    if (!"00".equals(obj) && ˊ.keySet().contains(obj)) {
                        arrayList.add(obj);
                    }
                }
            } catch (Exception e) {
                azh.ˏ.ˏ("ShowControlMore", "parseLeft error:" + str);
                arrayList.clear();
            }
        }
        return arrayList;
    }

    public void ˎ(View view) {
        if (this.ॱ == null || !ˏ.containsKey(this.ॱ)) {
            view.setVisibility(8);
            return;
        }
        view.setVisibility(0);
        ImageView imageView = (ImageView) view.findViewById(o.azf.a.ʻॱ);
        if (imageView != null) {
            imageView.setImageResource(((Integer) ˏ.get(this.ॱ)).intValue());
        }
    }

    public void ˎ(azv o_azv, bbe o_bbe) {
        int i = 1;
        if (o_bbe != null) {
            int i2 = (o_azv == null || !o_azv.ˎ()) ? 0 : 1;
            if (i2 != 0) {
                ˊ(o_azv, o_bbe);
            } else {
                o_bbe.ᐝ();
                i = 2;
            }
            ˋ(i, o_bbe);
        }
    }

    private void ˋ(int i, final bbe o_bbe) {
        boolean z;
        boolean z2;
        boolean z3 = false;
        o_bbe.ॱ(this.ˋ);
        if (this.ˎ != null && this.ˎ.size() > 0) {
            boolean z4;
            if (this.ˎ.size() > i) {
                z4 = true;
            } else {
                z4 = false;
            }
            Context context = o_bbe.ˎ().getContext();
            int i2 = 0;
            z = false;
            z2 = false;
            while (i2 < this.ˎ.size()) {
                if (z4 && i2 + 1 == i) {
                    o_bbe.ˏ(context.getResources().getDrawable(e.ˎ));
                    o_bbe.ʼ().setOnClickListener(new OnClickListener(this) {
                        final /* synthetic */ bal ˋ;

                        public void onClick(View view) {
                            this.ˋ.ˊ(o_bbe, i2);
                        }
                    });
                    z3 = true;
                    break;
                }
                baq ʼ = ʼ((String) this.ˎ.get(i2));
                ʼ.ˎ(context, o_bbe.ˏ(), o_bbe.ॱ());
                o_bbe.ˎ(i2, ʼ.ˎ(context), ʼ.ˏ()).setOnClickListener(new a(ʼ));
                if (i2 == 0) {
                    z2 = true;
                }
                if (i2 == 1) {
                    z = true;
                }
                i2++;
            }
        } else {
            z = false;
            z2 = false;
        }
        o_bbe.ˏ(z2, z, z3);
    }

    private void ˊ(azv o_azv, bbe o_bbe) {
        o_bbe.ॱॱ();
        o_bbe.ˊ().removeAllViews();
        o_azv.ˋ(o_bbe.ˊ());
    }

    private void ˊ(bbe o_bbe, int i) {
        if (this.ˎ != null && i < this.ˎ.size()) {
            Context context = o_bbe.ʼ().getContext();
            PopupMenu popupMenu = new PopupMenu(context, o_bbe.ʼ());
            for (int i2 = i; i2 < this.ˎ.size(); i2++) {
                baq ʼ = ʼ((String) this.ˎ.get(i2));
                if (ʼ != null) {
                    ʼ.ˏ(context, o_bbe.ˏ(), popupMenu.getMenu(), o_bbe.ॱ(), i2);
                }
            }
            o_bbe.ˋ(popupMenu);
            popupMenu.show();
        }
    }

    private baq ʼ(String str) {
        try {
            return (baq) ((Class) ˊ.get(str)).newInstance();
        } catch (Exception e) {
            azh.ˏ.ˏ("ShowControlMore", " menuCreatorClass.newInstance error");
            return null;
        }
    }
}
